Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kronos-integration/service

Package Overview
Dependencies
Maintainers
2
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kronos-integration/service

Base service implementation

  • 8.6.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
increased by90.25%
Maintainers
2
Weekly downloads
 
Created
Source

npm License minified size downloads Build Action Status semantic-release styled with prettier Commitizen friendly Known Vulnerabilities codecov.io Coverage Status

@kronos-integration/service

Base service implementation

API

Table of Contents

DESCRIPTION

key of the service description

Service

Extends EndpointsMixin(StateTransitionMixin(LogLevelMixin(events), prepareActions({ start: { stopped: rsfDefault }, restart: { stopped: rsfDefault, running: { target: "running", during: "restarting", timeout } }, stop: { running: ssfDefault, starting: ssfDefault, failed: ssfDefault } }), "stopped"))

Service The initial state is 'stopped' All services have at least three endpoints:

  • log out: log events
  • config in: configuration request
  • command in: administrative actions to be executed by the step

Parameters

  • config Object
    • config.name string
    • config.logLevel string
    • config.autostart boolean defaults to false
    • config.description string human readable description
    • config.endpoints Object will be merged with the build in ones
  • ic InitializationContext

extendetName

Used in human readable state messages. Besides the actual service name it may contain additional short hints

Returns string

stateChanged

Called when the service state changes. Emits a serviceStateChanged event to the owner

Parameters

rejectWrongState

Called when state transition is not allowed

Parameters
  • action string originating action name

  • Throws any always

timeoutForTransition

Deliver transtion timeout

Parameters

Returns number milliseconds before throwing for a long running transition

_start

Opens all endpoint connections

_stop

Closes all endpoint connections

_restart

Restart action default implementation does a _stop() and a _start()

Returns Promise fulfills after start

restartIfRunning

Restarts if in running mode Otherwise does nothing

Returns Promise resolves when restart is done (or immediate if no restart triggered)

toStringAttributes

Mapping of properties used in toString

Returns Object

toString

Returns the string representation of this service

Returns string human readable name

toJSONWithOptions

Deliver json representation

Parameters
  • options Object
    • options.includeRuntimeInfo boolean include runtime informtion like state
    • options.includeDefaults boolean include default endpoints
    • options.includeName boolean include name of the service
    • options.includeConfig boolean include config attributes

Returns Object json representation

name

defaults to the type

Returns string type

autostart

Should we start when beeing registered

Returns boolean false

_configure

Takes attribute values from config parameters and copies them over to the object. Copying is done according to configurationAttributes Which means we loop over all configuration attributes and then for each attribute decide if we use the default, call a setter function or simply assign the attribute value

Parameters

Returns Set of modified attributes

configure

Use new configuration. Internally calls _configure(config) as the constructor does If attribute with needsRestart are touched the restartIfRunning method will be called

Parameters

Returns Promise fillfills when config is applied

log

Adds service name to the log event

Parameters

configurationAttributes

Meta information for the config attributes.

  • default optional default value of the attribute
  • needsRestart optional modification requires a service restart
  • setter(newValue,attribute) optional function to be used if simple value assignment is not enough The Service class only defines the logLevel, and start/stop/restart timeout attribute

Returns Object

endpoints

Definition of the predefined endpoints

  • log out
  • config in
  • command in

Returns Object predefined endpoints

ServiceLogger

Extends Service

Log receiving service

autostart

We always start immediate

Returns boolean true

name

Returns string 'logger'

endpoints

Adds a log input endpoint to the set of Service endpoints

Returns Object predefined endpoints

ServiceConfig

Extends Service

Config providing service Dispatches config requests to services. or preserves them until a maching service becomes avaliable

Parameters

  • config
  • ic

Properties

  • preservedConfigs Map<string, Object> values for services not alredy established

configFor

Deliver configuration for a given servise

Parameters

clearPreserved

Forget about preserved config of a service

Parameters

configureValue

Set config entry

Parameters
  • key string path to the value
  • value any

configure

Parameters

autostart

We always start immediate

Returns boolean true

name

Returns string 'config'

merge

Merge from b into a When a and b are arrays of values only the none duplaces are appendend to a

Parameters

  • a any
  • b any

Returns any merged b into a

ServiceProviderMixin

Provide services and hold service configuration. By default a service provider has two build in services 'logger' and 'config'.

Parameters

  • superclass
  • serviceLoggerClass Class where the logging houtd go (optional, default ServiceLogger)
  • serviceConfigClass Class where the config comes from (optional, default ServiceConfig)

EndpointsMixin

Endpoint accessor mixin Manages endpoints in a container

Parameters

  • superclass Class class to be extended

Returns Class extended class

endpoints

default set of endpoints to create

Returns Object {} empty set

StandaloneServiceProvider

Extends ServiceProviderMixin(Service)

Simple service manager (for examples and testing only)

name

Returns string 'standalone-provider'

defineServiceConsumerProperties

Assign services based on a configuration

Parameters

InitializationContext

Keeps track of all in flight object creations and loose ends during config initialization

InitializationContext

Parameters

  • serviceProvider ServiceProvider
  • options Object
    • options.waitForFactories boolean wait until factory apears in registry

install

With npm do:

npm install @kronos-integration/service

license

BSD-2-Clause

FAQs

Package last updated on 27 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc